<html>
<head><meta charset="utf-8"><title>Chosing features with -Zbuild-std · t-cargo · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/index.html">t-cargo</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Chosing.20features.20with.20-Zbuild-std.html">Chosing features with -Zbuild-std</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="203236841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Chosing%20features%20with%20-Zbuild-std/near/203236841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> dbdr <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Chosing.20features.20with.20-Zbuild-std.html#203236841">(Jul 08 2020 at 06:59)</a>:</h4>
<p>Hi! I've been testing -Zbuild-std, great work!<br>
Is it possible to change stdlib features? (in particular I want to try disabling backtrace)</p>



<a name="203251314"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Chosing%20features%20with%20-Zbuild-std/near/203251314" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> dbdr <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Chosing.20features.20with.20-Zbuild-std.html#203251314">(Jul 08 2020 at 10:21)</a>:</h4>
<p>It seems that backtrace is hardcoded at the moment, so I tried this:</p>
<div class="codehilite"><pre><span></span><code>--- a/src/cargo/core/compiler/standard_lib.rs
+++ b/src/cargo/core/compiler/standard_lib.rs
@@ -99,7 +99,7 @@ pub fn resolve_std&lt;&#39;cfg&gt;(
     spec_pkgs.push(&quot;test&quot;.to_string());
     let spec = Packages::Packages(spec_pkgs);
     let specs = spec.to_package_id_specs(&amp;std_ws)?;
-    let features = vec![&quot;panic-unwind&quot;.to_string(), &quot;backtrace&quot;.to_string()];
+    let features = vec![&quot;panic-unwind&quot;.to_string(), /*&quot;backtrace&quot;.to_string()*/];
     // dev_deps setting shouldn&#39;t really matter here.
     let opts = ResolveOpts::new(
         /*dev_deps*/ false, &amp;features, /*all_features*/ false,
</code></pre></div>


<p>This makes the empty program go down in size from 148K to 56K, wow :)<br>
Is it a complicated story to make this option available?</p>



<a name="203272227"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Chosing%20features%20with%20-Zbuild-std/near/203272227" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Chosing.20features.20with.20-Zbuild-std.html#203272227">(Jul 08 2020 at 14:14)</a>:</h4>
<p>Currently there's no way to change features, and we haven't figure out a great way to do that right now</p>



<a name="203272249"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Chosing%20features%20with%20-Zbuild-std/near/203272249" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Chosing.20features.20with.20-Zbuild-std.html#203272249">(Jul 08 2020 at 14:14)</a>:</h4>
<p>the most likely way to do this, if any, will be global configuration</p>



<a name="203272271"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Chosing%20features%20with%20-Zbuild-std/near/203272271" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Chosing.20features.20with.20-Zbuild-std.html#203272271">(Jul 08 2020 at 14:14)</a>:</h4>
<p>I think it's pretty unlikely we'll support this on a crate-by-crate basis</p>



<a name="203300770"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Chosing%20features%20with%20-Zbuild-std/near/203300770" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> dbdr <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Chosing.20features.20with.20-Zbuild-std.html#203300770">(Jul 08 2020 at 17:58)</a>:</h4>
<p>I understand. Here's my vote for <em>some</em> way to configure std features. My test shows that disabling backtraces has a big effect on binary size, and it's a concern that comes up regularly, so it would be great to have an easy (for the user) way to make that choice.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>